package com.ki.erp.dao;

import com.ki.erp.model.Employee;
import jakarta.annotation.Resource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

@Component
public class EmployeeDaoImpl {
    public static final String EMPLOYEE = "employee";
    private @Resource MongoTemplate userTemplate;

    public List<Employee> getOFFEmployee(Date beginAt) {
        return userTemplate.find(query(where("status").is("OFF")
                        .and("resignDate").gte(beginAt)),
                Employee.class,
                EMPLOYEE);
    }
}
